package net.bbtang.website.utils;

/**
 * @作者：wangxuewei
 * @方法描述：作用于状态码反馈 依赖base状态码管理
 * @param <T>
 * @创建时间: 2014-10-23 下午12:57:38
 */
public class StatusCode<T> {
	private String number;//状态码
	private boolean flag = false;//状态码状态 0失败true 1成功false
	private String msg;//状态码值
	private String detailMsg;//状态码详细值
	private T data;
	
	public StatusCode() {
		
	}
	
	public StatusCode(String number) {
		this.number = number;
	}
	public StatusCode(Integer number) {
		this.number = number.toString();
	}
	
	public void codes(Integer number) {
		this.number = number.toString();
	}
	public void codes(Integer number,String detailMsg) {
		this.number = number.toString();
		this.detailMsg=detailMsg;
		if(nullOrBlankequalsNull(detailMsg)){
			this.detailMsg =this.msg;
		}
	}
	public void codes(Integer number,String detailMsg,T data) {
		this.number = number.toString();
		this.data = data;
		this.detailMsg=detailMsg;
		if(nullOrBlankequalsNull(detailMsg)){
			this.detailMsg =this.msg;
		}
	}

	
	public boolean isFlag() {
		return flag;
	}

	public void setFlag(boolean flag) {
		this.flag = flag;
	}

	public String getMsg() {
		return msg;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

	public void setDetailMsg(String detailMsg) {
		this.detailMsg = detailMsg;
	}

	public String getDetailMsg() {
		return detailMsg;
	}

	public String getNumber() {
		return number;
	}
	/**
	 * @作者：wangxuewei
	 * @方法描述：判断字符串是否为空值或null
	 * @param param
	 * @return boolean true表示存在空值或null false表示数据正常
	 * @创建时间: 2014-10-23 下午12:56:18
	 */
	private static boolean nullOrBlankequalsNull(String param) {
		return (param == null || param.length() == 0 || param.trim().equals("") || param
				.trim().toLowerCase().equals("null")) ? true : false;
	}
}
